package com.tiantianfresh.model.dao;

import com.tiantianfresh.model.pojo.CommodityAllocation;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author FANGAO
 * @date 2021/11/30 - 上午 11:05
 */
public interface CommodityAllocationMapper extends Mapper<CommodityAllocation> {
    /**
     * 获取每个商品的配置
     * @param comid
     * @return
     */
    @Select("select * from r_commodity_allocation where comid = #{comid} order by company ")
    List<CommodityAllocation> queryCommodityAllocationAll(@Param("comid") Integer comid);
    /**
     * 查询Allocation,返回list集合
     */
    List<CommodityAllocation> selectAll();

    /**
     * 根据id删除一个Allocation
     * @param id
     * @return
     */
    int deleteAllocationById(@Param("id") int id);

    /**
     * 增加一个Allocation
     * @param allocation
     * @return
     */
    int addAllocation(CommodityAllocation allocation);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    CommodityAllocation queryAllocationById(@Param("id") int id);

    /**
     * 更新Allocation
     * @param allocation
     * @return
     */
    int updateAllocation(CommodityAllocation allocation);

    /**
     * 修改订单配置状态
     * @param commodityAllocation
     * @return
     */
    @Update("update r_commodity_allocation set state = #{state} where caid = #{caid}")
    int updateState(CommodityAllocation commodityAllocation);
}
